package com.example.chapter13;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;

/*
 * 13.3.案例实施-写入文件内容
 * */
public class FileWriteExample {
    public static void main(String[] args) {
        String filePath = "path/to/your/output.txt";
        String[] data = {"Hello, ", "World!"};
        Path path = Paths.get(filePath);
        try {
            Files.write(path, Arrays.asList(data), StandardOpenOption.CREATE);
            System.out.println("File written successfully");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
